package com.im.easy.rxeasyandroidHelper.module.welcome.presenter;

import com.blankj.utilcode.util.LogUtils;
import com.im.easy.rxeasyandroidHelper.common.mvp.BasePresenter;
import com.im.easy.rxeasyandroidHelper.common.net.ApiService;
import com.im.easy.rxeasyandroidHelper.model.bean.welcome.WelcomeADInfo;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

import javax.inject.Inject;

public class WelcomeADPresenter extends BasePresenter<WelcomeADContract.View> implements WelcomeADContract.Presenter {

    @Inject
    ApiService apiService;

    @Inject
    public WelcomeADPresenter() {
    }

    @Override
    public void getData() {
        addSubscribe(apiService.getWelcomeADInfo()
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(
                    new Consumer<WelcomeADInfo>() {
                        @Override
                        public void accept(WelcomeADInfo welcomeADInfo) throws Exception {
                            getView().callback(true, welcomeADInfo);
                        }
                    }
                )
        );
    }
}
